set(op_DEPS core op_params)

# 1.basic ops used in basic models
add_operator(conv_op basic SRCS conv_op.cc)
add_operator(pool_op basic SRCS pool_op.cc)
add_operator(fc_op basic SRCS fc_op.cc)
add_operator(mul_op basic SRCS mul_op.cc)
add_operator(matmul_op basic SRCS matmul_op.cc)
add_operator(scale_op basic SRCS scale_op.cc)
add_operator(softmax_op basic SRCS softmax_op.cc)
add_operator(reshape_op basic SRCS reshape_op.cc)
add_operator(batch_norm_op basic SRCS batch_norm_op.cc)
add_operator(feed_op basic SRCS feed_op.cc)
add_operator(fetch_op basic SRCS fetch_op.cc)
add_operator(activation_basic_ops basic SRCS activation_ops.cc)
add_operator(elementwise_ops basic SRCS elementwise_ops.cc)
add_operator(box_coder_op_lite basic SRCS box_coder_op.cc)
add_operator(multiclass_nms_op_lite basic SRCS multiclass_nms_op.cc)
add_operator(fill_constant_op basic SRCS fill_constant_op.cc)
add_operator(fill_constant_batch_size_like_op basic SRCS fill_constant_batch_size_like_op.cc)
add_operator(shuffle_channel_op basic SRCS shuffle_channel_op.cc)
add_operator(yolo_box_op basic SRCS yolo_box_op.cc)
add_operator(interpolate_op basic SRCS interpolate_op.cc)
add_operator(interpolate_v2_op basic SRCS interpolate_v2_op.cc)
add_operator(argmax_op basic SRCS argmax_op.cc)
add_operator(prior_box_op basic SRCS prior_box_op.cc)
add_operator(concat_op basic SRCS concat_op.cc)
add_operator(pad2d_op basic SRCS pad2d_op.cc)
add_operator(calib_op basic SRCS calib_op.cc)
add_operator(split_op basic SRCS split_op.cc)
add_operator(transpose_op basic SRCS transpose_op.cc)
add_operator(fake_quant extra SRCS fake_quantize_moving_avg_max_abs.cc)
add_operator(fake_dequant extra SRCS fake_dequantize_max_abs.cc)
add_operator(conv_transpose_op basic SRCS conv_transpose_op.cc)
add_operator(expand_op_lite basic SRCS expand_op.cc)
add_operator(expand_as_op_lite basic SRCS expand_as_op.cc)
add_operator(squeeze_op_lite basic SRCS squeeze_op.cc)
add_operator(unsqueeze_op_lite basic SRCS unsqueeze_op.cc)
add_operator(stack_op basic SRCS stack_op.cc)
add_operator(cast_op_lite basic SRCS cast_op.cc)
add_operator(affine_channel_op basic SRCS affine_channel_op.cc)
add_operator(affine_grid_op basic SRCS affine_grid_op.cc)
add_operator(range_op basic SRCS range_op.cc)
add_operator(reduce_ops basic SRCS reduce_ops.cc)
add_operator(relu_op basic SRCS relu_op.cc)
add_operator(io_copy_op basic SRCS io_copy_op.cc)
add_operator(fusion_elementwise_activation_ops basic SRCS fusion_elementwise_activation_ops.cc)
add_operator(io_copy_once_op basic SRCS io_copy_once_op.cc)
add_operator(dropout_op basic SRCS dropout_op.cc)
add_operator(layout_op basic SRCS layout_op.cc)
add_operator(layout_once_op basic SRCS layout_once_op.cc)
add_operator(instance_norm_op basic SRCS instance_norm_op.cc)
add_operator(subgraph_op basic SRCS subgraph_op.cc)
add_operator(grid_sampler_op basic SRCS grid_sampler_op.cc)
add_operator(flatten_op basic SRCS flatten_op.cc)
add_operator(write_back_op basic SRCS write_back_op.cc)
add_operator(lod_array_length_op basic SRCS lod_array_length_op.cc)

add_operator(pow_op extra SRCS pow_op.cc)
add_operator(sign_op extra SRCS sign_op.cc)
add_operator(rnn_op extra SRCS rnn_op.cc)

# 2.basic ops not used in basic models
add_operator(negative_op extra SRCS negative_op.cc)
add_operator(crop_op extra SRCS crop_op.cc)
add_operator(crop_tensor_op extra SRCS crop_tensor_op.cc)
add_operator(assign_op extra SRCS assign_op.cc)
add_operator(group_norm_op extra SRCS group_norm_op.cc)
add_operator(norm_op extra SRCS norm_op.cc)

# 3.extra ops
add_operator(reverse_op extra SRCS reverse_op.cc)
add_operator(inverse_op extra SRCS inverse_op.cc)
add_operator(sparse_conv_op extra SRCS sparse_conv_op.cc)
add_operator(search_group_padding extra SRCS search_group_padding_op.cc)
add_operator(lrn_op_lite extra SRCS lrn_op.cc)
add_operator(decode_bboxes_op_lite extra SRCS decode_bboxes_op.cc)
add_operator(uniform_random_op extra SRCS uniform_random_op.cc)
add_operator(axpy_op extra SRCS axpy_op.cc)
add_operator(correlation_op extra SRCS correlation_op.cc)
add_operator(gru_unit_op extra SRCS gru_unit_op.cc)
add_operator(gru_op extra SRCS gru_op.cc)
add_operator(density_prior_box_op basic SRCS density_prior_box_op.cc)
add_operator(calib_once_op extra SRCS calib_once_op.cc)
add_operator(shape_op_lite extra SRCS shape_op.cc)
add_operator(sequence_expand_op_lite extra SRCS sequence_expand_op.cc)
add_operator(sequence_unpad_op_lite extra SRCS sequence_unpad_op.cc)
add_operator(sequence_pad_op_lite extra SRCS sequence_pad_op.cc)
add_operator(sequence_mask_op_lite extra SRCS sequence_mask_op.cc)
add_operator(im2sequence_op extra SRCS im2sequence_op.cc)
add_operator(gather_nd_op extra SRCS gather_nd_op.cc)
add_operator(gather_op extra SRCS gather_op.cc)
add_operator(gather_tree_op extra SRCS gather_tree_op.cc)
add_operator(anchor_generator_op extra SRCS anchor_generator_op.cc)
add_operator(generate_proposals_op extra SRCS generate_proposals_op.cc)
add_operator(generate_proposals_v2_op extra SRCS generate_proposals_v2_op.cc)
add_operator(roi_align_op extra SRCS roi_align_op.cc)
add_operator(box_clip_op extra SRCS box_clip_op.cc)
add_operator(fake_quantize_range_abs_max_op extra SRCS fake_quantize_range_abs_max.cc)
add_operator(sequence_expand_as_op_lite extra SRCS sequence_expand_as_op.cc)
add_operator(assign_value_op basic SRCS assign_value_op.cc)
add_operator(fake_quantize_dequantize_moving_avg_abs_max_op extra SRCS fake_quantize_dequantize_moving_avg_max_abs.cc)
add_operator(fake_quantize_dequantize_abs_max_op extra SRCS fake_quantize_dequantize_abs_max.cc)
add_operator(fake_channel_wise_quantize_dequantize_abs_max_op extra SRCS fake_channel_wise_quantize_dequantize_abs_max.cc)
add_operator(fake_channel_wise_dequantize_max_abs_op extra SRCS fake_channel_wise_dequantize_max_abs.cc)
add_operator(split_lod_tensor_op_lite extra SRCS split_lod_tensor_op.cc)
add_operator(merge_lod_tensor_op_lite extra SRCS merge_lod_tensor_op.cc)
add_operator(sequence_reshape_op_lite extra SRCS sequence_reshape_op.cc)
add_operator(sequence_reverse_op_lite extra SRCS sequence_reverse_op.cc)
add_operator(sequence_pool extra SRCS sequence_pool_op.cc)
add_operator(sequence_conv extra SRCS sequence_conv_op.cc)
add_operator(sequence_pool_concat extra SRCS sequence_pool_concat_op.cc)
add_operator(sequence_reverse_embedding_op_lite extra SRCS sequence_reverse_embedding_op.cc)
add_operator(match_matrix_tensor_op_lite extra SRCS match_matrix_tensor_op.cc)
add_operator(search_seq_depadding_op_lite extra SRCS search_seq_depadding_op.cc)
add_operator(search_grnn_op_lite extra SRCS search_grnn_op.cc)
add_operator(search_seq_softmax_op_lite extra SRCS search_seq_softmax_op.cc)
add_operator(sequence_concat_op_lite extra SRCS sequence_concat_op.cc)
add_operator(var_conv_2d_op_lite extra SRCS var_conv_2d_op.cc)
add_operator(attention_padding_mask_op_lite extra SRCS attention_padding_mask_op.cc)
add_operator(sequence_arithmetic_op_lite extra SRCS sequence_arithmetic_op.cc)
add_operator(conditional_block_op_lite extra SRCS conditional_block_op.cc)
add_operator(collect_fpn_proposals_op_lite extra SRCS collect_fpn_proposals_op.cc)
add_operator(distribute_fpn_proposals_op_lite extra SRCS distribute_fpn_proposals_op.cc)
add_operator(crf_decoding_op_lite extra SRCS crf_decoding_op.cc)
add_operator(ctc_align_op_lite extra SRCS ctc_align_op.cc)
add_operator(cumsum_op_lite extra SRCS cumsum_op.cc)
add_operator(polygon_box_transform_op_lite extra SRCS polygon_box_transform_op.cc)
add_operator(max_pool_with_index_op extra SRCS max_pool_with_index_op.cc)
add_operator(pixel_shuffle_op extra SRCS pixel_shuffle_op.cc)
add_operator(clip_op extra SRCS clip_op.cc)
add_operator(print_op extra SRCS print_op.cc)
add_operator(scatter extra SRCS scatter_op.cc)
add_operator(matrix_nms_op_lite extra SRCS matrix_nms_op.cc)
add_operator(sin_op extra SRCS sin_op.cc)
add_operator(cos_op extra SRCS cos_op.cc)
add_operator(cos_sim_op extra SRCS cos_sim_op.cc)
add_operator(unstack_op extra SRCS unstack_op.cc)
add_operator(pad3d_op extra SRCS pad3d_op.cc)
add_operator(select_input_op extra SRCS select_input_op.cc)
add_operator(tensor_array_to_tensor_op extra SRCS tensor_array_to_tensor_op.cc)
add_operator(fill_any_like_op extra SRCS fill_any_like_op.cc)
add_operator(fill_zeros_like_op extra SRCS fill_zeros_like_op.cc)
add_operator(matmul_v2_op extra SRCS matmul_v2_op.cc)
add_operator(sum_op extra SRCS sum_op.cc)
add_operator(expand_v2_op_lite extra SRCS expand_v2_op.cc)
add_operator(tile_op extra SRCS tile_op.cc)
add_operator(scatter_nd_add_op extra SRCS scatter_nd_add_op.cc)
add_operator(tril_triu_op extra SRCS tril_triu_op.cc)
add_operator(meshgrid_op_lite extra SRCS meshgrid_op.cc)
add_operator(linspace_op extra SRCS linspace_op.cc)
add_operator(roi_perspective_transform_op extra SRCS roi_perspective_transform_op.cc)
add_operator(argsort_op extra SRCS argsort_op.cc)
add_operator(flip_op extra SRCS flip_op.cc)
add_operator(index_select_op extra SRCS index_select_op.cc)

# for OCR specific
add_operator(while_op extra SRCS while_op.cc)
add_operator(lookup_table_op extra SRCS lookup_table_op.cc)
add_operator(lookup_table_dequant_op extra SRCS lookup_table_dequant_op.cc)
add_operator(lookup_table_v2_op extra SRCS lookup_table_v2_op.cc)
add_operator(beam_search_decode_op extra SRCS beam_search_decode_op.cc)
add_operator(logical_xor  extra SRCS logical_op.cc)
add_operator(logical_and  extra SRCS logical_op.cc)
add_operator(logical_or  extra SRCS logical_op.cc)
add_operator(logical_not  extra SRCS logical_op.cc)
add_operator(less_than  extra SRCS compare_op.cc)
add_operator(equal  extra SRCS compare_op.cc)
add_operator(not_equal  extra SRCS compare_op.cc)
add_operator(less_equal  extra SRCS compare_op.cc)
add_operator(greater_than  extra SRCS compare_op.cc)
add_operator(greater_equal  extra SRCS compare_op.cc)
add_operator(read_from_array_op extra SRCS read_from_array_op.cc)
add_operator(beam_search_op extra SRCS beam_search_op.cc)
add_operator(lod_reset_op extra SRCS lod_reset_op.cc)
add_operator(is_empty extra SRCS is_empty_op.cc)
add_operator(slice_op_lite basic SRCS slice_op.cc)
add_operator(write_to_array_op extra SRCS write_to_array_op.cc)
add_operator(topk_op extra SRCS topk_op.cc)
add_operator(topk_v2_op extra SRCS topk_v2_op.cc)
add_operator(increment_op extra SRCS increment_op.cc)
add_operator(layer_norm_op extra SRCS layer_norm_op.cc)
add_operator(sequence_softmax_op extra SRCS sequence_softmax_op.cc)
add_operator(retinanet_detection_output_op extra SRCS retinanet_detection_output_op.cc)
add_operator(where_index_op extra SRCS where_index_op.cc)
add_operator(one_hot_op extra SRCS one_hot_op.cc)
add_operator(one_hot_v2_op extra SRCS one_hot_v2_op.cc)
add_operator(strided_slice_op extra SRCS strided_slice_op.cc)
add_operator(where_op extra SRCS where_op.cc)
add_operator(unique_with_counts_op extra SRCS unique_with_counts_op.cc)

# for content-dnn specific
add_operator(search_aligned_mat_mul_op extra SRCS search_aligned_mat_mul_op.cc)
add_operator(search_seq_fc_op extra SRCS search_seq_fc_op.cc)
add_operator(sequence_topk_avg_pooling_op basic SRCS sequence_topk_avg_pooling_op.cc)
add_operator(search_fc_op basic SRCS search_fc_op.cc)
add_operator(lstm_op extra SRCS lstm_op.cc)
add_operator(topk_pooling_op extra SRCS topk_pooling_op.cc)
# for deformable-convNet
add_operator(deformable_conv_op extra SRCS deformable_conv_op.cc)

# 4. training op
add_operator(mean_op extra SRCS mean_op.cc)

add_operator(mean_grad_op train SRCS mean_grad_op.cc)
add_operator(activation_grad_ops train SRCS activation_grad_ops.cc)
add_operator(elementwise_grad_op train SRCS elementwise_grad_ops.cc)
add_operator(mul_grad_op train SRCS mul_grad_op.cc)
add_operator(sgd_op train SRCS sgd_op.cc)
add_operator(sequence_pool_grad train SRCS sequence_pool_grad_op.cc)

# Only for XPU
add_operator(__xpu__resnet50_op extra SRCS __xpu__resnet50_op.cc)
add_operator(__xpu__softmax_topk_op extra SRCS __xpu__softmax_topk_op.cc)
add_operator(__xpu__multi_encoder_op extra SRCS __xpu__multi_encoder_op.cc)
add_operator(__xpu__embedding_with_eltwise_add_op extra SRCS __xpu__embedding_with_eltwise_add_op.cc)
add_operator(__xpu__fc_op extra SRCS __xpu__fc_op.cc)
add_operator(__xpu__resnet_cbam_op extra SRCS __xpu__resnet_cbam_op.cc)
add_operator(__xpu__search_attention_op extra SRCS __xpu__search_attention_op.cc)
add_operator(__xpu__mmdnn_op extra SRCS __xpu__mmdnn_op.cc)
add_operator(__xpu__conv2d_op extra SRCS __xpu__conv2d_op.cc)
add_operator(__xpu__sfa_head_op extra SRCS __xpu__sfa_head_op.cc)
add_operator(__xpu__generate_sequence_op extra SRCS __xpu__generate_sequence_op.cc)
add_operator(__xpu__logit_op extra SRCS __xpu__logit_op.cc)
add_operator(__xpu__squeeze_excitation_op extra SRCS __xpu__squeeze_excitation_op.cc)
add_operator(__xpu__bigru_op extra SRCS __xpu__bigru_op.cc)
add_operator(__xpu__dynamic_lstm_fuse_op extra SRCS __xpu__dynamic_lstm_fuse_op.cc)
add_operator(__xpu__multi_softmax_op extra SRCS __xpu__multi_softmax_op.cc)

# Only for FPGA
add_operator(fpga_conv_op extra SRCS __fpga__conv_op.cc)

add_library(ops STATIC ${OPS_SRC} op_params.cc)
add_dependencies(ops utils)

if (NOT LITE_WITH_X86)
    if(NOT LITE_WITH_ARM)
        lite_cc_test(test_one_hot_op SRCS one_hot_op_test.cc)
    endif()
    lite_cc_test(test_fc_op SRCS fc_op_test.cc)
    lite_cc_test(test_pool_op SRCS pool_op_test.cc)
    lite_cc_test(test_scale_op SRCS scale_op_test.cc)
    lite_cc_test(test_softmax_op SRCS softmax_op_test.cc)
    lite_cc_test(test_batch_norm_op SRCS batch_norm_op_test.cc)
    lite_cc_test(test_concat_op SRCS concat_op_test.cc)
    lite_cc_test(test_calib_op SRCS calib_op_test.cc)
    lite_cc_test(test_transpose_op SRCS transpose_op_test.cc)
    lite_cc_test(test_fusion_elementwise_activation_ops
                 SRCS fusion_elementwise_activation_ops_test.cc)
endif()
